<template>
     <div class="good_list">
          <div class="good_item" v-for="(item ,index) in commoditylist " :key="index" @click="listto((item.id))">
              <img :src="item.img_url" alt="">
              <h3>{{item.tatal}}</h3>
               <div class="goog_new">
                  <p class="good_price">
                      <span>￥{{item.sell_price}}</span>
                      <span>￥{{item.market_price}}</span>
                  </p>
                  <p class="good_size">
                      <span>热卖中</span>
                      <span>剩{{item.stock_quantity}}件</span>
                  </p>
              </div>
          </div>
           <mt-button type="danger" size="large" @click="getMore">加载更多</mt-button>
     </div>
</template>
<script>
import {addgoodlist}  from '@/api/index.js'
export default {
    data(){
        return{
            commoditylist:[],
            pagesize:1
        }
    },
    created() {
        this.goodslist()
    },
    methods:{
        goodslist(){
            addgoodlist(this.pagesize).then(res =>{
               if(res.status === 0){
                 this.commoditylist = this.commoditylist.concat(res.message);
                }
            })
        },
        getMore(){
           this.pagesize++ 
           this.goodslist()
        },
        listto(id){
          this.$router.push({ path: "/goodslist/goodlistof/" + id });
        }
  
    }
}
</script>

<style lang="scss" scoped>
 .good_list{
  display: flex;
  flex-wrap: wrap;
  padding: 7px;
  justify-content: space-between;
  .good_item{
    width: 49%;
    border: 1px solid #ccc;
    box-shadow: 0 0 8px #ccc;
    margin: 4px 0;
    padding: 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 293px;
    img{
      width: 100%;
    }
    h3{
      font-size: 14px;
    }

    .goog_new{
      background-color: #eee;
      p{
        margin: 0;
        padding: 5px;
      }
      .good_price{
        :nth-child(1){
          color: red;
          font-weight: bold;
          font-size: 16px;
        }
        :nth-child(2){
          text-decoration: line-through;
          font-size: 12px;
          margin-left: 15px;
        }
      }
      .good_size{
        display: flex;
        justify-content: space-between;
        font-size: 13px;
      }
    }
  }
}
</style>

